// forcetalk.txt
// Liek alknpc, but this character will aprroach and speak with character first time.
// Memory Cells:
//   Cell 0 - If 0, default behavior. If 1, it doesnt fidget.
//   Cell 1 - Number of state when talked to. Plays default text if 0.
//   Cell 2,3 -  Stuff done flag. if it is 0, this character hunts party down
//   Cell 4 - Speaking range. Range pc is within to hunt down. Default to 12.
begincreaturescript;

variables;

short i,target;
short has_greeted = 0;
short speak_range = 12;
short anger_ct = 0;
short last_abil;

body;

beginstate INIT_STATE;
	speak_range = 3;
	set_name(ME,"Sickly Artila");
	if (gf(0,1) > 0)
		erase_char(ME);
	last_abil = get_current_tick();
		
	break;

beginstate DEAD_STATE;
break;

beginstate START_STATE;
	// if I have a target for some reason, go attack it
	if (target_ok()) {
		set_state(3);
		}
	
	if (get_foe_target(ME,8,0)) {
		do_attack();
		set_state(3);
		}
	if (who_shot_me() >= 0) {
		set_foe_target(ME,who_shot_me());
		do_attack();
		set_state(3);
		}

					
	if ((dist_to_pc() <= speak_range) && ( has_greeted == 0)) {
		has_greeted = 1;
		begin_talk_mode(110);
		}
	if ((dist_to_pc() <= speak_range) && ( has_greeted > 0) && (get_attitude(ME) < 10)) {
		if (tick_difference(last_abil,get_current_tick()) > 0) {
			anger_ct = anger_ct + 1;
			if (anger_ct < 5)
				print_str_color("The artila is growing more agitated.",3);
				else {
					set_attitude(ME,10);
					begin_talk_mode(111);
					}
			last_abil = get_current_tick();
			}
		}


break;

beginstate 3; // attacking
	if (target_ok() == FALSE)
		set_state(START_STATE);
	do_attack();
break;


beginstate TALKING_STATE;
	if ( has_greeted == 0) {
		has_greeted = 1;
		begin_talk_mode(110);
		}
		else print_str_color("Talking: The artila hisses at you.",2);

break;